import request from '@/utils/request'

/**
 *  查询产品信息
 * @returns
 */
export function listProduct(params) {
  return request({
    url: '/admin/product/list',
    method: 'post',
    data: {
      pageNum: params.pageNum,
      limit: params.limit,
      cityId: params.cityId,
      provinceId: params.provinceId,
      date: params.date
    }
  })
}

/**
 * 新增商品信息
 * @returns
 */
export function insertProduct(form) {
  return request({
    url: '/admin/product/save',
    method: 'post',
    data: {
      productName: form.productName,
      categoryId: form.categoryId,
      sellPrice: form.sellPrice,
      sitePrice: form.sitePrice,
      stock: form.stock,
      provinceId: form.provinceId,
      cityId: form.cityId,
      img: form.img,
      address: form.address,
      date: form.date,
      grade: form.grade,
      venueId: form.venueId,
      trafficId: form.trafficId,
      platformId: form.platformId,
      delayId: form.delayId,
      guestList: form.guestList,
      typeId: form.typeId,
      price: form.price
    }
  })
}

/**
 * 根据商品id 获取商品信息
 * @param {} productId
 * @returns
 */
export function getProduct(productId) {
  return request({
    url: '/admin/product/' + productId,
    method: 'get',

  })
}

/**
 * 修改商品信息
 * @param {*} params
 * @returns
 */
export function updateProduct(form, productId) {
  return request({
    url: '/admin/product',
    method: 'put',

    data: {
      productId: productId,
      productName: form.productName,
      categoryId: form.categoryId,
      sellPrice: form.sellPrice,
      sitePrice: form.sitePrice,
      stock: form.stock,
      provinceId: form.provinceId,
      cityId: form.cityId,
      skuImg: form.skuImg,
      address: form.address,
      date: form.date,
      grade: form.grade,
      venueId: form.venueId,
      trafficId: form.trafficId,
      platformId: form.platformId,
      delayId: form.delayId,
      guestList: form.guestList

    }
  })
}

/**
 * 根据商品id删除商品
 * @param {*} productId
 * @returns
 */
export function deleteProductById(productId) {
  return request({
    url: '/admin/product/' + productId,
    method: 'delete',

  })
}
